﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Process
{
    [ComVisible(true)]
    public class ProcessController
    {
        public virtual void Load()
        {
            //MessageBox.Show("进入");
        }

        public virtual void UnLoad()
        {
            //MessageBox.Show("退出");
        }

        public virtual void Call(string type, string obj)
        {
            //MessageBox.Show("调用");
        }

        public virtual void Timeout()
        {

        }

        public void Render(object inObjs, string id)
        {
            ProcessEngine.Instance.RenderPage(inObjs, id);
        }

        public void Render(object inObjs, string id, bool isShow)
        {
            ProcessEngine.Instance.RenderPage(inObjs, id, isShow);
        }

        public void RunScript(string script)
        {
            ProcessEngine.Instance.RunScript(script);
        }

        public void CreateTimeout(int tiem, string id)
        {
            ProcessEngine.Instance.CreateTimeout(tiem, id);
        }

        public void Go(string url)
        {
            //MessageBox.Show("跳转到" + url);
            ProcessEngine.Instance.GoPage(url);
        }

        public void GoBack()
        {
            string lastPage = ProcessEngine.Instance.LockedPage;
            ProcessEngine.Instance.GoPage(lastPage);
        }

        public void ReLoad()
        {
            ProcessEngine.Instance.ReLoadPage();
        }

        public void Lock(string url)
        {
            ProcessEngine.Instance.LockPage(url);
        }

        public T JSON2Object<T>(string data)
        {
            return ProcessEngine.Instance.DataDeserialize<T>(data);
        }

        public string Object2JSON(object obj)
        {
            return ProcessEngine.Instance.DataSerialize(obj);
        }

        public void Init(string url)
        {
            ProcessEngine.Instance.SetController(url);
        }

        public void Exit()
        {
            ProcessEngine.Instance.Exit();
        }
    }
}
